package com.itheima.controller;

import com.itheima.domain.Info;
import com.itheima.domain.Patient;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@ResponseBody
@RequestMapping("/user")
public class OfficeController {

    @Autowired
    private UserService userService;
    @RequestMapping("/addPatient")
    public void addPatient(String name,String gender,String office){
        userService.addOne(name,gender,office);
    }

    @RequestMapping("/selectGenderAndOffice")
    public Info selectGenderAndOffice(){
        Info info = userService.selectGenderAndOffice();
        System.out.println(info);
        for (String s : info.getOfficeName()) {
            System.out.println(s);
        }
        return info;
    }

    @RequestMapping("/selectAll")
    public List<Patient> selectAll(){
        List<Patient> patientList = userService.selectAll();
        return patientList;
    }
}
